{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.11-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python361164bitpytrochcondae51393cc87754f83a49faf18fa04379a",
   "display_name": "Python 3.6.11 64-bit ('pytroch': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np \n",
    "import csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_global_setting = pd.read_csv( './Cura/c_global_setting_2.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "(587, 2)"
      ]
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "df_global_setting.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "                      kys                          value\n",
       "540  mesh_rotation_matrix  \"[[1,0,0], [0,1,0], [0,0,1]]\""
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>kys</th>\n      <th>value</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>540</th>\n      <td>mesh_rotation_matrix</td>\n      <td>\"[[1,0,0], [0,1,0], [0,0,1]]\"</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "df_global_setting[df_global_setting['kys'] == \"mesh_rotation_matrix\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "### 读取打印机设置说明与挤出机配置说明\n",
    "df_fdm_set_info = pd.read_csv('./cfg/fdmprinter_cn.csv')\n",
    "df_extruder_set_info =pd.read_csv('./cfg/fdmextruder_cn.csv')"
   ]
  },
  {
   "source": [
    "### 下面进行合并"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_fdm_setting_info_1 = pd.merge(df_global_setting,df_fdm_set_info,on='kys',how='left')\n",
    "df_fdm_setting_info_2 = pd.merge(df_fdm_setting_info_1,df_extruder_set_info,on=\"kys\",how='left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df_fdm_setting_info_2.head(20)\n",
    "df_fdm_setting_info_2.to_excel(\"./2-添加了说明信息的全局配置2.xlsx\",index=False)"
   ]
  },
  {
   "source": [
    "### 下面对挤出机配置信息进行补全"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_extruder_setting = pd.read_csv('./Cura/c_extruder_setting_2.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "(463, 2)"
      ]
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "df_extruder_setting.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_extruder_setting_info_1 = pd.merge(df_extruder_setting,df_fdm_set_info,on='kys',how='left')\n",
    "df_extruder_setting_info_2 = pd.merge(df_extruder_setting_info_1,df_extruder_set_info,on=\"kys\",how='left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "(463, 6)"
      ]
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "df_extruder_setting_info_2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_extruder_setting_info_2.to_excel(\"2-添加了说明信息的挤出机配置2.xlsx\",index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}